package com.cskaoyan.mall.service.implement;

import com.cskaoyan.mall.dao.AdminDao;
import com.cskaoyan.mall.dao.implement.AdminDaoImpl;
import com.cskaoyan.mall.model.sql.Admin;
import com.cskaoyan.mall.model.sql.Result;
import com.cskaoyan.mall.service.AdminService;
import com.cskaoyan.mall.model.bo.*;

import java.util.List;

public class AdminServiceImpl implements AdminService {
    private AdminDao adminDao = new AdminDaoImpl();

    @Override
    public List<Admin> allAdmins() {
        return adminDao.allAdmins();
    }

    @Override
    public Admin login(AdminLoginBO loginBO) {
        Admin admin = new Admin();
        admin.setEmail(loginBO.getEmail());
        admin.setPwd(loginBO.getPwd());

        // adminDao.xxx方法(loginBO)
        // adminDao.xxx1(updateBO)
        // adminDao.xxx(admin)  (admin 统一loginBO和upadteBO，admin对应数据库表,loginBO和updateBO是前端业务)
        return adminDao.login(admin);
    }

    @Override
    public void addAdminss(AdminAddBO addBO) {
        adminDao.addAdminss(addBO);
    }

    @Override
    public void deleteAdmins(String id) {
        adminDao.deleteAdmins(id);
    }

    @Override
    public Admin getAdminsInfo(String id) {
        return adminDao.getAdminsInfo(id);
    }

    @Override
    public void updateAdminss(Admin changeBO) {
         adminDao.updateAdminss(changeBO);
    }

    @Override
    public Result changePwd(AdminChangePwdBO changePwdBO) {
        return adminDao.changePwd(changePwdBO);
    }

    @Override
    public List<Admin> getSearchAdmins(AdminSearchBO searchBO) {
        Admin admin = new Admin();
        admin.setEmail(searchBO.getEmail());
        admin.setNickname(searchBO.getNickname());
        return adminDao.getSearchAdmins(admin);
    }
}
